Xbasic

cn_open Function

Syntax

cn_open(SQL::Connection cn, C connectionStr [, C username, C password])

Arguments

cnSQL::Connection

A SQL::Connection object.

connectionStrCharacter

A data source connection. The connection can either be a named or explicit connection string. Specify "<default>" to use the default connection string defined in Project Properties.

usernameCharacter

Connection user name.

Character

Connection password.

Returns

resultLogical

Returns .t. if the connection is successfully opened. Otherwise, returns .f.. Check the SQL::Connection's CallResult property for error details.

Description

Opens a connection to a data source.

Discussion

Opens a connection to a data source specified by a named connection string.

Example

dim cn as sql::connection
if (cn_open(cn,"<default>") then
else
    dim cr as SQL::CallResult = cn.callResult
    dim errorText as c = cr.text

    trace.writeLn("Error opening connection. Reason: " + errorText,"SQLLog")
end if

See Also